<?php
	if(isset($_REQUEST['control'])){
		include("user_verify.php");
	}
?>
    <div id="wrapper">

        <div id="page-wrapper">
            <div class="row">
             
				 <div class="box-header">
                    <h1 class="page-header">User Controls</h1> <a class="btn btn-default" href="index.php?page=user_controls&action=user_add">New User</a></div> 
				 </div><!-- /.box-header -->	
				<?php 
			if(@$errors!=""){
				echo " <td colspan=\"3\"><span class='red'>". @$errors."</span></td>";
			}else{
				if(isset($_REQUEST['msgStatus']))
					echo " <td colspan=\"3\"><span class='red'>". $_REQUEST['msgStatus']."</span></td>";
			 }
			?>
            </div>
            <!-- /.row -->
           <div class="box">
                        <div class="panel-heading">
                           List All Users<div>
                        </div>
						
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                          <div class="box-body table-responsive">
                                <table id="example1" class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>Photo</th>
                                            <th>Full Name</th>
                                            <th>Login</th>
											 <th>Telephone</th>
                                            <th>Email</th>
                                            <th>Remark</th>
											
                                        </tr>

                                    </thead>
                                    <tbody>
									<?php
           // $sql = "SELECT u.user_id,u.gro_id,u.full_name,u.user_login AS user_name,u.active,u.email,u.photo,l.loc_name,g.gro_name 
			//		FROM tbl_user AS u INNER JOIN tbl_group AS g ON u.gro_id=g.gro_id INNER JOIN tbl_location
				//    AS l ON u.loc_id=l.loc_id ORDER BY u.user_id DESC ";
				$sql="SELECT user_id,full_name,user_login,active,email,phone,photo,remark ,active FROM tbl_user WHERE 1";
				
            $result = mysql_query($sql);
            while ( $row = mysql_fetch_object($result)){
            ?>
			
                                        <tr class="odd gradeX">
                                            <td><img src="users/<?php $photo=$row->photo; echo $photo;  ?>" width="80" height="auto"  /></td>
                                            <td><?php echo $row->full_name; ?></td>
                                            <td><?php echo $row->user_login; ?></td>
                                            <td class="center"><?php echo $row->phone; ?></td>
                                            <td class="center"><?php echo $row->email; ?></td>
											<td><?php echo $row->remark; ?></td>
											<td>
                    <?php 
                      $icon_publish = $row->active==0 ? "publish_x.png" : "publish_y.png";
                      $publish_image = "<img width='15px' src='images/{$icon_publish}' />";														
                    ?>
                      <a href="index.php?page=user_controls&action=user_controls&control=publish&active=<?php echo $row->active. "&user_id=" . $row->user_id;?>">
                    <?php echo $publish_image; ?></a>
                </td>
                <td>
                	<a href="index.php?page=user_controls&action=user_add&user_id=<?php echo $row->user_id	; ?>"><img src="images/edit.png" border="0" alt="Edit"></a> | <a href="index.php?page=user_controls&action=user_controls&control=delete&user_id=<?php echo $row->user_id; ?>&photo=<?php echo $photo;?>" onclick="return confirm('Are you sure want to delete?');"><img src="images/delete.png" border="0" alt="delete"></a>
                </td>
        </tr>
       <?php 
      }
   ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            

    </div>
    <!-- /#wrapper -->
